﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WinFormClient
{
    //这个没用 没想好这个有什么用;
    public class ClientEventArgs : EventArgs
    {
        public enum EventType
        {
            TOPIC,
            GROUP,
            MESSAGE,
         }
        public EventType type;
        public WinFormClient.ClientEventArgs.EventType Type
        {
            get { return type; }
            set { type = value; }
        }
        public string content;
        public string Content
        {
            get { return content; }
            set { content = value; }
        }
        public Message msg;
        public WinFormClient.Message Message
        {
            get { return msg; }
            set { msg = value; }
        }
    }

    public class Client : WinFormClient.IViewController
    {
        public int debug;
        ClientDataCenter myDataCenter;
        
        //public event EventHandler<ClientEventArgs> ShowMsg;
        public event EventHandler FinishedLoadGroup;
        public event EventHandler FinishedLoadTopic;
        public event EventHandler FinishedLoadReplies;
        public event EventHandler FinishedLoadUserInfo;
        public event EventHandler ShowErrorMsg;

        public Client()
        {
            myDataCenter = new ClientDataCenter();
        }

        public void FetchUserInfo()
        {
            UserInfo user;
            user = myDataCenter.data.userinfo;
            FinishedLoadUserInfo(user, null);
        }

        public void Login()
        {
            throw new NotImplementedException();
        }

        public void FetchGroups()
        {
            GroupSet groups = new GroupSet();
            FinishedLoadGroup(groups, null);     
        }

        public void Exit()
        {
            myDataCenter.LocalSave();
        }

        public void FetchTopics(int groupid)
        {
            TopicSet topics = new TopicSet(groupid);
            FinishedLoadTopic(topics,null);
            throw new System.NotImplementedException();
        }

        public void FetchReplies(int topicid)
        {
            MessageSet msgs = new MessageSet(topicid);
            FinishedLoadReplies(msgs, null);
            throw new System.NotImplementedException();
        }

        public void AddTopic()
        {
            throw new System.NotImplementedException();
        }

        public void DeleteTopic()
        {
            throw new System.NotImplementedException();
        }

        public void SignUp()
        {
            throw new System.NotImplementedException();
        }

    }
}
